﻿using CalculatorLib;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace CalculatorLib.Test
{
    
    [TestClass]
    public class MathLibTestWithStub
    {

        private MathLib _lib;

        [TestInitialize]
        public void SetupLib()
        {
            StubPiWebService ws = new StubPiWebService();
            _lib = new MathLib(ws);
        }

        [TestMethod]
        public void CircumferenceIsComputedCorrectly()
        {
            float result = _lib.ComputeCircumference(3f);
            Assert.AreEqual(18.8496f, result);
        }

        [TestMethod]
        public void MassIsComputedCorrectly()
        {
            float result = _lib.CalculateMass(80f,"Milano");
            Assert.AreEqual(8.16f, result,0.01f);
        }

    }

    internal class StubPiWebService: IPiWebService
    {
        public float GetPi()
        {
            return 3.1416f;
        }

        public float GetGravity(string location)
        {
            return 9.8f;
        }
    }
}
